package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.pojo.dto.QuestionConnectDTO;
import com.example.demo.pojo.entity.QuestionBank;
import com.example.demo.pojo.entity.QuestionClassification;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author fjh
 */
@Mapper
public interface QuestionClassificationMapper extends BaseMapper<QuestionClassification> {
    //查询
    //全部获取
    @Select("SELECT * FROM test.question_classification")
    List<QuestionClassification>initQuestionClassifications();
    //根据根节点进行查找
    @Select("SELECT * FROM test.question_classification where node_id like CONCAT( #{rootId}, '-','%')")
    List<QuestionClassification>initQuestionClassificationByRootId(Integer rootId);
    //根据nodeId进行查找--进行虚数查找
    @Select("SELECT * FROM test.question_classification where node_id like CONCAT( #{nodeId},'%')")
    List<QuestionClassification>getQuestionClassificationByNodeId(String nodeId);
    @Select("select * FROM test.question_classification where  question_label_id=#{labelId}")
    List<QuestionClassification>getQuestionClassificationByLabelId(Integer labelId);
    //根据根节点进行查找并分组
    @Select("SELECT question_bank_id FROM test.question_classification where node_id like CONCAT( #{rootId}, '-','%') group by question_bank_id")
    List<QuestionClassification>groundQuestionClassificationByRootId(Integer rootId);
    //根据题型id查找==查找实题目
    @Select("SELECT question_bank_id FROM test.question_classification where question_label_id =#{labelId}")
    List<Integer>initQuestionClassificationByLabelId(Integer labelId);
    //根据nodeId进行模糊查询并分组==查找虚题目
    @Select("SELECT question_bank_id FROM test.question_classification where node_id like CONCAT( #{nodeId},'%') group by question_bank_id")
    List<Integer>initQuestionClassificationByLabelNodeId(String nodeId);
    //根据题目id进行查找--全部
    @Select("select * from test.question_classification where question_bank_id=#{bankId}")
    List<QuestionClassification>searchQuestionClassificationByBankId(int bankId);
    //根据题目id进行查找--题型id
    @Select("select question_label_id from test.question_classification where question_bank_id=#{bankId}")
    List<Integer>searchLabelIdListByBankId(int bankId);


    //xml映射文件
    List<QuestionConnectDTO>getRealNumber(@Param("categoryId")Integer categoryId, @Param("labelId")Integer labelId);

    List<QuestionConnectDTO>getImageNumber(@Param("categoryId")Integer categoryId,@Param("nodeId")String  nodeId);

    List<Integer>getBankList(@Param("categoryId")Integer categoryId, @Param("labelId")Integer labelId);

}
